﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default : System.Web.UI.Page
{
    public string refLink = "http://www.shuyixia.com/";
    protected void Page_Load(object sender, EventArgs e)
    {
        string fromUser = Request.Params[ConstStrings.RefUser] as string;
        string ip = Request.UserHostAddress;
        if (fromUser != null)
        {
            global::User user = UserManager.GetInstance().FindUser(fromUser);
            if (user != null)
            {
                UserRef userRef = new UserRef() { UserName = fromUser, Ip = ip, Time = DateTime.Now };
                if (UserManager.GetInstance().IsValidUserRef(userRef))
                {
                    UserManager.GetInstance().UpdateUserRef(userRef);

                    user.Money += 2;
                    Session[ConstStrings.RefUser] = fromUser;
                }
            }
        }
        if (User.Identity.IsAuthenticated)
        {
            refLink += "?refUser=";
            refLink += User.Identity.Name;
        }
       
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {

    }
}